Hello,
could anyone tell me, if there exists already an elegant method/function which can be used for extracting the content of a SkipList into a new static array representation?
In my case, I have a SkipList with string values. These string values must be shipped over to a method only accepting a string[] as input. Thus, I need to extract the SkipList contents into a string array representation. Before calling that method, there is no alternative for using an other representation then the SkipList, because i have to reidentify certain values by using the key mechanism.
Many thanks in advance, Helko
Helko - Fri Jan 06 09:59:15 EST 2012 |
|
Re: Extract SkipList content into array content PatrickGuay - Fri Jan 06 13:13:21 EST 2012
This should help, or put you on the right track:
void fill_array_with_combo_items(Skip &dictionary_values_skip, string combo_definition[]) {
Skip value_inner_skip = dictionary_values_skipVALUE Skip;
int count = skiptools_count(value_inner_skip)
println("The count is: " count "")
int choices_i
for(choices_i = 0 ; choices_i < count ; choices_i++) {
combo_definitionchoices_i = value_inner_skipchoices_i
}
delete value_inner_skip
}
as for a neat already existing method to do this... In the world of DXL you usually have to do it yourself.
Regards,
|
|
Re: Extract SkipList content into array content PatrickGuay - Fri Jan 06 13:14:36 EST 2012 PatrickGuay - Fri Jan 06 13:13:21 EST 2012
This should help, or put you on the right track:
void fill_array_with_combo_items(Skip &dictionary_values_skip, string combo_definition[]) {
Skip value_inner_skip = dictionary_values_skipVALUE Skip;
int count = skiptools_count(value_inner_skip)
println("The count is: " count "")
int choices_i
for(choices_i = 0 ; choices_i < count ; choices_i++) {
combo_definitionchoices_i = value_inner_skipchoices_i
}
delete value_inner_skip
}
as for a neat already existing method to do this... In the world of DXL you usually have to do it yourself.
Regards,
There are square brackets around the blue words
|
|
Re: Extract SkipList content into array content PatrickGuay - Fri Jan 06 14:47:25 EST 2012 PatrickGuay - Fri Jan 06 13:13:21 EST 2012
This should help, or put you on the right track:
void fill_array_with_combo_items(Skip &dictionary_values_skip, string combo_definition[]) {
Skip value_inner_skip = dictionary_values_skipVALUE Skip;
int count = skiptools_count(value_inner_skip)
println("The count is: " count "")
int choices_i
for(choices_i = 0 ; choices_i < count ; choices_i++) {
combo_definitionchoices_i = value_inner_skipchoices_i
}
delete value_inner_skip
}
as for a neat already existing method to do this... In the world of DXL you usually have to do it yourself.
Regards,
Here is the missing method skiptools_count
int skiptools_count(Skip &skpIn) {
int res = 0
for anyType in skpIn do
res++
return res
}
|
|
Re: Extract SkipList content into array content llandale - Mon Jan 09 18:36:32 EST 2012 PatrickGuay - Fri Jan 06 13:13:21 EST 2012
This should help, or put you on the right track:
void fill_array_with_combo_items(Skip &dictionary_values_skip, string combo_definition[]) {
Skip value_inner_skip = dictionary_values_skipVALUE Skip;
int count = skiptools_count(value_inner_skip)
println("The count is: " count "")
int choices_i
for(choices_i = 0 ; choices_i < count ; choices_i++) {
combo_definitionchoices_i = value_inner_skipchoices_i
}
delete value_inner_skip
}
as for a neat already existing method to do this... In the world of DXL you usually have to do it yourself.
Regards,
I am not following this completely; don't see what value_inner_skip is about.
But it appears that the caller must already have declared "combo_definition[]" large enough to handle all values of the Skip; which means your function should probably return the count so the caller knows how many it can use.
functions do not pass back arrays well, and the "method" may presume the entire array.
I think the solution may look like this:
int count = skiptools_count(value_inner_skip)
string combo_definition[count]
string Data, Key
int i = 0
for Data in dictionary_values_skip do
{ if (I want the "key" values) then
{ Key = (string key dictionary_values_skip)
combo_definition[i++] = Key
}
else combo_definition[i++] = Data // I want the "data" in the skip
}
use combo_definition in your method.
-Louie
|
|
Re: Extract SkipList content into array content PatrickGuay - Tue Jan 10 08:29:49 EST 2012
I extracted these methods from one of my scripts which use embedded skip lists. I did not attempt to supply an actual working script. It was more of a guideline to adapt to his need.
I indeed call skiptools_count() in order to pre-count the skip items so that I can declare the array with a given size. I then send the string array to the method.
|
|